package com.lidy.tankbattle.tankgame2.bomb;

import com.lidy.tankbattle.tankgame2.constant.BombPriorities;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lidy
 * @version V2.0
 * @classname Bomb
 * @description 炸弹
 * @date 2022/6/2 19:07
 */
@Data
public class Bomb {

    /**
     * 炸弹X坐标
    **/
    private int x;

    /**
     * 炸弹Y坐标
    **/
    private int y;

    /**
     * 炸弹声明周期
    **/
    private int left;

    /**
     * 炸弹是否存活
     **/
    private Boolean live = true;

    /**
     * 炸弹图片地址
    **/
    private List<String> bombAddress;

    public Bomb(int x, int y, int left, List<String> bombAddress) {
        this.x = x;
        this.y = y;
        this.left = left;
        this.bombAddress = bombAddress;
    }

    /**
     * @author: lidy
     * @description: 炸弹生命周期减少
     * @date: 2022/6/6 20:26
     */
    public void reduceBombLeft() {
        left--;
        if (left <= 0) {
            live = false;
        }
    }

    /**
     * @author: lidy
     * @description: 获取坦克爆炸炸弹
     * @date: 2022/6/7 20:49
     */
    public static Bomb getTankBomb(int x, int y) {
        return new Bomb(x, y, BombPriorities.BOMB_LEFT, BombPriorities.TANK_BOMB_ADDRESS_LIST);
    }

    /**
     * @author: lidy
     * @description: 获取墙体爆炸炸弹
     * @date: 2022/6/7 20:56
     */
    public static Bomb getWallBomb(int x, int y) {
        return new Bomb(x, y, BombPriorities.BOMB_LEFT, BombPriorities.WALL_BOMB_ADDRESS_LIST);
    }
}
